package touchtrack;

import java.awt.Image;
import java.awt.image.PixelGrabber;

import processing.core.PImage;

/**
 * Settings class.
 * 
 * @author	MuMe09 team 6
 * 			http://mumetech.wordpress.com/
 */
public class Settings
{
	public static final String LAST_FM_API_KEY = "b25b959554ed76058ac220b7b2e0a026";
	public static final int MAX_SIMILAR_TRACKS = 3;
    public static final int SPRING_COLOR = 255;
    public static final String FONT = "LucidaSans-12.vlw";
	
	/**
	 * Fix for stupid error in Processing.
	 * 
	 * @param 	Image img
	 * @return	PImage
	 */
	public static PImage toPImage(Image img)
	{
		PImage tmp = null;
		
		int width = img.getWidth(null);
		int height = img.getHeight(null);
		int[] pixels = new int[width * height];
		
		PixelGrabber pg = new PixelGrabber(img, 0, 0, width, height, pixels, 0, width);
		try {
			pg.grabPixels();
		} catch (InterruptedException e) { }
		
		tmp = new PImage(width,height);
		tmp.loadPixels();
		
		for (int i = 0; i < width * height; i++) {
			tmp.pixels[i] = pixels[i];
		}
		
		tmp.updatePixels();
		
		return tmp;
	}
}